package com.jo.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Jo
 * @date 2017/12/7
 */
@Configuration
public class RabbitConfig {
    public static final String EXCHANGE_NAME = "springboot-topicExchange";

    public static final String QUEUE_NAME = "springboot-queue";
    //声明队列
    @Bean
    public Queue queue1() {
        return new Queue("springboot-queue", true); // true表示持久化该队列
    }

    //声明交互器
    @Bean
    TopicExchange topicExchange() {
        return new TopicExchange("springboot-topicExchange", true, true);
    }

    //绑定
    @Bean
    public Binding binding1() {
        return BindingBuilder.bind(queue1()).to(topicExchange()).with("springboot.#");
    }

}
